<template>
  <el-card>
    <template #header>
      <div class="clearfix">
        <span>优惠券列表</span>
        <el-button @click="router.push('/home/partner/investors/add')" style="float: right; padding: 3px 0" type="text">添加</el-button>
      </div>
    </template>
    <el-table :data="couponsList" style="width: 100%">
      <el-table-column prop="id" label="序号"></el-table-column>
      <el-table-column prop="couponName" label="礼券名称" ></el-table-column>
      <el-table-column prop="couponType" label="礼券类型" ></el-table-column>
      <el-table-column prop="faceValue" label="面额" >
        <template #default="scope">
          ¥{{ scope.row.faceValue }}
        </template>
      </el-table-column>
      <el-table-column prop="validPeriod" label="有效期" ></el-table-column>
      <el-table-column prop="applicableRange" label="适用范围" ></el-table-column>
      <el-table-column prop="usageConditions" label="使用条件" ></el-table-column>
      <el-table-column prop="status" label="状态" ></el-table-column>
      <el-table-column prop="createdAt" label="创建时间">
        <template #default="scope">
          {{ scope.row.createdAt.substring(0, 10) }}
        </template>
      </el-table-column>
    </el-table>
  </el-card>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { fetchCouponsList } from "../../../../api/CouponsApi.ts";
import router from "../../../../router";

const couponsList = ref([]);

const getCouponsList = async () => {
  const res = await fetchCouponsList();
  if (res.code === 200) {
    couponsList.value = res.data
  }
};


getCouponsList();

</script>

<style scoped>
.el-card {
  margin-top: 20px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  box-shadow: 0 0 0 #ffffff;
  outline: 0;
}
</style>
